﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsProjectDetailDAL
/// </summary>
public class clsProjectDetailDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsProjectDetailDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public List<IN_TB_USER_PROJECT> GetAllProject()
    {
        try
        {
            List<IN_TB_USER_PROJECT> objIN_TB_USER_PROJECT = new List<IN_TB_USER_PROJECT>();
            objIN_TB_USER_PROJECT = (from obj in objInstantNaukriDataContextDataContext.IN_TB_USER_PROJECTs
                                     select obj).ToList();
            return objIN_TB_USER_PROJECT;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_USER_PROJECT GetProjectById(int ID)
    {
        try
        {
            IN_TB_USER_PROJECT objIN_TB_USER_PROJECT = new IN_TB_USER_PROJECT();
            objIN_TB_USER_PROJECT = (from obj in objInstantNaukriDataContextDataContext.IN_TB_USER_PROJECTs
                                     where obj.ID == ID
                                     select obj).SingleOrDefault();
            return objIN_TB_USER_PROJECT;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public List<IN_TB_USER_PROJECT> GetProjectByUserId(int UserId)
    {
        try
        {
            List<IN_TB_USER_PROJECT> objIN_TB_USER_PROJECT = new List<IN_TB_USER_PROJECT>();
            objIN_TB_USER_PROJECT = (from obj in objInstantNaukriDataContextDataContext.IN_TB_USER_PROJECTs
                                     where obj.USERID == UserId
                                     select obj).ToList();
            return objIN_TB_USER_PROJECT;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveProject(IN_TB_USER_PROJECT objIN_TB_USER_PROJECT)
    {
        try
        {
            IN_TB_USER_PROJECT objIN_TB_USER_PROJECTD = new IN_TB_USER_PROJECT();
            objIN_TB_USER_PROJECTD = (from obj in objInstantNaukriDataContextDataContext.IN_TB_USER_PROJECTs
                                      where obj.ID == objIN_TB_USER_PROJECT.ID
                                      select obj).SingleOrDefault();
            if (objIN_TB_USER_PROJECTD != null)
            {
                objIN_TB_USER_PROJECTD.ID = objIN_TB_USER_PROJECT.ID;
                objIN_TB_USER_PROJECTD.USERID = objIN_TB_USER_PROJECT.USERID;
                objIN_TB_USER_PROJECTD.EMPLOYER_NAME = objIN_TB_USER_PROJECT.EMPLOYER_NAME;
                objIN_TB_USER_PROJECTD.PROJECT_TITLE = objIN_TB_USER_PROJECT.PROJECT_TITLE;

                objIN_TB_USER_PROJECTD.DURATION_START = objIN_TB_USER_PROJECT.DURATION_START;
                objIN_TB_USER_PROJECTD.DURATION_END = objIN_TB_USER_PROJECT.DURATION_END;
                objIN_TB_USER_PROJECTD.DESIGNATION = objIN_TB_USER_PROJECT.DESIGNATION;
                objIN_TB_USER_PROJECTD.PROJECT_LOCATION = objIN_TB_USER_PROJECT.PROJECT_LOCATION;
                objIN_TB_USER_PROJECTD.PROJECT_DETAILS = objIN_TB_USER_PROJECT.PROJECT_DETAILS;
                objIN_TB_USER_PROJECTD.ROLE = objIN_TB_USER_PROJECT.ROLE;
                objIN_TB_USER_PROJECTD.ROLE_DESCRIPTION = objIN_TB_USER_PROJECT.ROLE_DESCRIPTION;
                objIN_TB_USER_PROJECTD.TEAM_SIZE = objIN_TB_USER_PROJECT.TEAM_SIZE;
                objIN_TB_USER_PROJECTD.SKILLS_USED = objIN_TB_USER_PROJECT.SKILLS_USED;
                objIN_TB_USER_PROJECTD.EMPLOYMENT_TYPE = objIN_TB_USER_PROJECT.EMPLOYMENT_TYPE;
                objIN_TB_USER_PROJECTD.EXPERIENCE = objIN_TB_USER_PROJECT.EXPERIENCE;
                objIN_TB_USER_PROJECTD.CREATED_BY = objIN_TB_USER_PROJECT.CREATED_BY;
                objIN_TB_USER_PROJECTD.CREATED_ON = objIN_TB_USER_PROJECT.CREATED_ON;
                objIN_TB_USER_PROJECTD.MODIFIED_BY = objIN_TB_USER_PROJECT.MODIFIED_BY;
                objIN_TB_USER_PROJECTD.MODIFIED_ON = objIN_TB_USER_PROJECT.MODIFIED_ON;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_USER_PROJECTD.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_USER_PROJECTs.InsertOnSubmit(objIN_TB_USER_PROJECT);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_USER_PROJECT.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
}
